﻿using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public class FileController
{
    public static List<string> GetMusicFilesNameByRoot(string path)
    {
        List<string> res = new List<string>();
        DirectoryInfo folder = new DirectoryInfo(path);
        foreach (var file in folder.GetFiles())
        {
            if (file.Name.EndsWith(".mp3") || file.Name.EndsWith(".wav") || file.Name.EndsWith(".aiff") || file.Name.EndsWith(".flac"))
            {
                res.Add(file.Name.Remove(file.Name.IndexOf(".")));
            }
        }

        foreach (var directoryInfo in folder.GetDirectories())
        {
            foreach (var file in directoryInfo.GetFiles())
            {
                if (file.Name.EndsWith(".mp3") || file.Name.EndsWith(".wav") || file.Name.EndsWith(".aiff") || file.Name.EndsWith(".flac"))
                {
                    res.Add(directoryInfo.Name + "/" + file.Name.Remove(file.Name.IndexOf(".")));
                }
            }
        }

        return res;
    }

    public static DirectoryInfo[] GetChildFolderByRoot(string path)
    {
        DirectoryInfo folder = new DirectoryInfo(path);
        return folder.GetDirectories();
    }
}